<?php

namespace app\controller;

use app\BaseController;

use think\facade\Db;

class Info extends BaseController
{

    //新增/编辑
    public function save()
    {
        $data = input('');
        $re = Db::table('qc_info')->save($data);
        if ($re) {
            return reJson($re, 200, '成功');
        } else {
            return reJson([], 500, '失败');
        }
    }

    //删除
    public function delete()
    {
        $data = input('');
        $re = Db::table('qc_info')->delete($data);
        if ($re) {
            return reJson($re, 200, '成功');
        } else {
            return reJson([], 500, '失败');
        }
    }

    //列表
    public function list()
    {
        $data = input('');

        $orderKey = isset($data['orderKey']) ? $data['orderKey'] : 'id';
        $orderSort = isset($data['orderSort']) ? $data['orderSort'] : 'desc';

        $re = Db::table('qc_info')->order($orderKey, $orderSort)->paginate([
            'list_rows' => 10,
            'page' => $data['page'],
        ]);
        if ($re) {
            return reJson($re, 200, '成功');
        } else {
            return reJson([], 500, '失败');
        }
    }
}
